home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / gui / uberwidgets / ubersplit.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  5KB  |  114 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import wx
  5. from gui import skin
  6. from gui.uberwidgets import UberWidget
  7. from util import try_this
  8.  
  9. class UberSplitter(wx.SplitterWindow, UberWidget):
  10.     
  11.     def __init__(self, parent):
  12.         wx.SplitterWindow.__init__(self, parent, style = wx.SP_NOBORDER | wx.SP_LIVE_UPDATE)
  13.         b = self.Bind
  14.         b(wx.EVT_LEFT_DCLICK, (lambda e: pass))
  15.         b(wx.EVT_ERASE_BACKGROUND, (lambda e: pass))
  16.         b(wx.EVT_PAINT, self._UberSplitter__paint)
  17.         b(wx.EVT_SPLITTER_SASH_POS_CHANGED, self._UberSplitter__changed)
  18.         b(wx.EVT_ENTER_WINDOW, self._UberSplitter__enter)
  19.         b(wx.EVT_LEAVE_WINDOW, self._UberSplitter__leave)
  20.         b(wx.EVT_LEFT_DOWN, self._UberSplitter__ldown)
  21.  
  22.     
  23.     def __ldown(self, e):
  24.         e.Skip()
  25.         self.Refresh()
  26.  
  27.     
  28.     def __enter(self, e):
  29.         e.Skip()
  30.         self.Refresh()
  31.  
  32.     
  33.     def __leave(self, e = None):
  34.         if e:
  35.             e.Skip()
  36.         
  37.         self.Refresh()
  38.  
  39.     
  40.     def __motion(self, e):
  41.         e.Skip()
  42.         if self.HasCapture() and not self.SplitRect.Inside(e.Position):
  43.             self._UberSplitter__leave()
  44.         
  45.  
  46.     
  47.     def __changed(self, e):
  48.         wx.CallAfter(self.Refresh)
  49.  
  50.     
  51.     def SplitHorizontally(self, w1, w2):
  52.         self.SetSkinKey('HorizontalSizerBar', True)
  53.         wx.SplitterWindow.SplitHorizontally(self, w1, w2)
  54.  
  55.     
  56.     def SplitVertically(self, w1, w2):
  57.         self.SetSkinKey('HorizontalSizerBar', True)
  58.         wx.SplitterWindow.SplitVertically(self, w1, w2)
  59.  
  60.     
  61.     def UpdateSkin(self):
  62.         key = self.skinkey
  63.         
  64.         s = lambda k, default = (sentinel,): skin.get('%s.%s' % (key, k), default)
  65.         self.SetSashSize((try_this,)((lambda : int(s('Thickness'))), 4))
  66.         self.icon = s('Icon', None)
  67.         self.bg = s('Backgrounds.Normal')
  68.         self.bghover = s(('Backgrounds.Hover',), (lambda : self.normalbg))
  69.         self.bgactive = s(('Backgrounds.Active',), (lambda : self.hoverbg))
  70.  
  71.     
  72.     def __paint(self, e):
  73.         dc2 = wx.PaintDC(self)
  74.         r = self.SplitRect
  75.         if r is None:
  76.             return e.Skip()
  77.         
  78.         bg = 'bg'
  79.         if wx.FindWindowAtPointer() is self:
  80.             bg = None if wx.LeftDown() else 'bghover'
  81.         
  82.         (None, wx.CallAfter)((lambda : getattr(self, bg).Draw(wx.ClientDC(self), self.SplitRect)))
  83.  
  84.     
  85.     def SplitRect(self):
  86.         w1 = self.Window1
  87.         w2 = self.Window2
  88.         if w1 is None or w2 is None:
  89.             return None
  90.         
  91.         r1 = w1.Rect
  92.         r2 = w2.Rect
  93.         if self.SplitMode == wx.SPLIT_VERTICAL:
  94.             return wx.Rect(r1.Right, 0, r2.X, self.Size.height)
  95.         else:
  96.             return wx.Rect(0, r1.Bottom, self.Size.width, r2.Y)
  97.  
  98.     SplitRect = property(SplitRect)
  99.  
  100. if __name__ == '__main__':
  101.     from tests.testapp import testapp
  102.     a = testapp('../../../')
  103.     f = wx.Frame(None)
  104.     split = wx.SplitterWindow(f)
  105.     split.SetBackgroundColour(wx.RED)
  106.     p1 = wx.Panel(split)
  107.     p1.BackgroundColour = wx.WHITE
  108.     p2 = wx.Panel(split)
  109.     p2.BackgroundColour = wx.WHITE
  110.     split.SplitHorizontally(p1, p2)
  111.     f.Show()
  112.     a.MainLoop()
  113.  
  114.